# -*- coding: utf-8 -*-
'''
Created on 2011-8-21

@author: zxz
'''
from sqlalchemy import Column, BigInteger, Numeric, String, DateTime
from datasource import Base
from common.DateUtil import getStdTimeStr

class Comments(Base):
    ''' 回复 '''
    __tablename__ = 'comments'
    id = Column(BigInteger, primary_key=True)
    sid = Column(BigInteger, nullable=False)
    uid = Column(BigInteger, nullable=False)
    content = Column(String(500), nullable=False)
    gmt_create = Column(DateTime, nullable=False)

    def __init__(self, sid, uid, content, gmt_create):
        self.sid = sid
        self.uid = uid
        self.content = content
        self.gmt_create = gmt_create

    def __repr__(self):
        return '<Comments %r>' % self.id

    def entity(self):
        return {'id':self.id, 'sid' : self.sid, 'uid' : self.uid, 'content' : self.content, 'gmt_create' : getStdTimeStr(self.gmt_create)}
